package ${parentPack}.controller.admin;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import ${parentPack}.entity.${tableName};
import ${parentPack}.util.PageBean;
import ${parentPack}.util.Page;
import ${parentPack}.entity.User;
import ${parentPack}.service.${tableName}Service;
import ${parentPack}.util.ResponseUtil;
import ${parentPack}.util.SessionUtil;

/**
 *	${tableRemarks}管理
 * @author Administrator
 *
 */
@Controller
@RequestMapping("/admin/${tableValue}")
public class ${tableName}Controller {
	
	@Autowired
	private ${tableName}Service ${tableValue}Service;
	
	/**
	 * 添加
	 */
	@RequestMapping("/add")
	public void add(${tableName} ${tableValue},HttpServletResponse response){
		ResponseUtil.writeSuccess(response, "添加成功");
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	public void delete(Integer id,HttpServletResponse response){
		${tableValue}Service.deleteById(id);
		ResponseUtil.writeSuccess(response, "删除成功");
	}
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	public void list( PageBean pageBean, ${tableName} ${tableValue},HttpServletResponse response) throws Exception{
		List<${tableName}> ${tableValue}s = ${tableValue}Service.findByPage(new Page<${tableName}>(pageBean, ${tableValue}));;
		Integer total = ${tableValue}Service.getTotal(${tableValue});
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm").create();
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("data", ${tableValue}s);
		map.put("count", total);
		map.put("code", 0);
		map.put("msg", "");
		ResponseUtil.write(response, gson.toJson(map));
	}
	
}




















